
<?php
$obluutam = $this->rsOder;
//var_dump($obluutam);
?>
<header class ="panel-heading">
	<strong>Danh Mục Order</strong>
</header>

<div class="panel-body">
	<form action="#" class="form-horizontal tasi-form">
					<div class="form-group">
						<label class="control-label col-md-2">Chọn Ngày Order</label>
						<div class="col-md-4 col-xs-10">
							<input class="form-control form-control-inline input-medium default-date-picker"  size="16" type="text" value=""  id="dteNgaydatmon" />
						</div>
						<div class="col-md-2 col-xs-10" style="margin-top: -10px">
							<button type="button" class="btn btn-primary" id="btnlaydshoadon">Lấy danh sách món</button>
						</div>
					</div>
					<div class="tags_clear"></div>
	</form>
	<div class="adv-table editable-table ">		
	  <div role="grid" class="dataTables_wrapper form-inline" id="editable-sample_wrapper">		
		<table id="tbOrder" class="table table-striped table-hover table-bordered dataTable" aria-describedby="editable-sample_info">		
			<thead>
				<tr role="row">
					<th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 10px;" aria-label="Username">Stt</th>
					<th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 168px;" aria-label="Username">Tên bàn</th>
					<th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 168px;" aria-label="Username">Tên Món</th>
					<th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 168px;" aria-label="Username">Số lượng</th>
					<th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" style="width: 78px;" >Thời Gian</th>	
					<th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" style="width: 70px;" aria-label="Delete: activate to sort column ascending"></th>				
				</tr>
		  </thead>
		  
		  <tbody role="alert" aria-live="polite" aria-relevant="all">
			  <?php 
			  $stt = 0;
			  foreach($this->rsOder as $rs) { 
				$stt++;
				?>
			  <tr>
				  <td class="  sorting_1"><?php echo $stt ?></td>
				  <td class="  sorting_1"><?php echo $rs['TenBan'] ?></td>	
				  <td class="  sorting_1"><?php echo $rs['TenMon'] ?></td>		
				  <td class="  sorting_1"><?php echo $rs['Soluong'] ?></td>
				  <td class=" "> <?php echo date_format(date_create($rs['Ngaydatmon']), 'H:i:s') ?></td>		
				  <td style="text-align: center">				  		
				  		<a class="red thuchien" href="javascript:;" data="<?php echo $rs['Id']?>" >Thực hiện</a></td>			  
				  </td>		  	
			  </tr>
			  <?php } ?>
		</tbody>
		</table>
  </div>
	</div>
</div>

<script> var _baseURL = "<?php echo _BASE_URL?>"; </script>
<script>
if (top.location != location) {
    top.location.href = document.location.href ;
}

$(function(){
	window.prettyPrint && prettyPrint();
    $('.default-date-picker').datepicker ({
        format: 'dd-mm-yyyy'
    });
});


$('#btnlaydshoadon').click(function(){	
	
	if($('#dteNgaydatmon').val()=="")
	{
		alert("Vui lòng chọn ngày order!");
		return;
	}
	var ngaydatmon = $('#dteNgaydatmon').val();
	$("#dteNgaydatmon").val(ngaydatmon);
	location.href= _baseURL + "default/index/vieworder/Ngaydatmon/" +  $('#dteNgaydatmon').val();	
	

});

//$('#btnthuchien').click(function() {
$(".thuchien").click(function(){
	var url = "?php echo _BASE_URL?>/api/index/updatetrangthaiorder";
	var Id = $(this).attr('data');	
	var kiemtra = -1;
	var formData = {Id: Id, kiemtra:kiemtra}; //Array

	var tr = $(this).closest('tr');
	$.ajax({
		url: url,
		type: "POST",
		data: formData,
		success: function(data, textStatus, jqXHR)
		{
			alert('Đã thực hiện');
			deleteRowofTable(tr)
		},
		error: function (jqXHR, textStatus, errorThrown)
		{
			alert('Thất bại');
		} 
	});		
	
});
function deleteRowofTable(tr)
{
	tr.css("background-color","#FF3700");
		tr.fadeOut(400, function(){
		tr.remove();
	});
}

function LoadOrder()
{
	//alert('44');
}

setInterval(LoadOrder, 3000);



</script>
        